package math

import (
	"ch05/instructions/base"
	"ch05/rtda"
)

type IINC struct {
	Index uint
	Const int32
}


func (self *IINC) FetchOperands (reader *base.BytecodeReader) {
	self.Index = uint(reader.ReadUint8())
	self.Const = int32(reader.ReadInt8())
}


func (self *IINC) Execute (frame rtda.Frame) {
	localVals := frame.LocalVars()
	val := localVals.GetInt(self.Index)
	val+=self.Const
	localVals.SetInt(self.Index,val)
}
